package com.limh.gobang.bean

import android.graphics.Point
import android.os.Parcel
import android.os.Parcelable

/**
 * @author limh
 * @function
 * @date 2018/5/4 11:04
 */
class Fight() :Parcelable{
    //是否先手
    var isFirst: Boolean = false
    //落子颜色
    var color: String? = ""
    //落子位置
    var point: Point? = null

    constructor(parcel: Parcel) : this() {
        isFirst = parcel.readByte() != 0.toByte()
        color = parcel.readString()
        point = parcel.readParcelable(Point::class.java.classLoader)
    }

    override fun writeToParcel(parcel: Parcel, flags: Int) {
        parcel.writeByte(if (isFirst) 1 else 0)
        parcel.writeString(color)
        parcel.writeParcelable(point, flags)
    }

    override fun describeContents(): Int {
        return 0
    }

    companion object CREATOR : Parcelable.Creator<Fight> {
        override fun createFromParcel(parcel: Parcel): Fight {
            return Fight(parcel)
        }

        override fun newArray(size: Int): Array<Fight?> {
            return arrayOfNulls(size)
        }
    }
}
